package com.volkanic.stages.menu;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.volkanic.background.BackgroundImage;
import com.volkanic.buttons.MenuButton;
import com.volkanic.stages.SharedStage;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by Lucas on 22/07/2014.
 */
public class BackGroundStage extends SharedStage {

    private List<BackgroundImage> _backgroundsList;

    public BackGroundStage(){
        _backgroundsList = new ArrayList<BackgroundImage>();
        _backgroundsList.add(CreateBackGround("textures/back-montain.png", 0.6f, -10f));
        _backgroundsList.add(CreateBackGround("textures/front-montain.png", 0.40f, -9f));
        _backgroundsList.add(CreateBackGround("textures/front.png", 0.35f, -8f));

        this.addButtonsToStage();
    }

    private BackgroundImage CreateBackGround(String pathToTexture, float speed, float curY){
        Gdx.app.debug("tag", "Creating BackGround Menu");
        Vector2 position = new Vector2(this.X_CENTER, curY * this.HEIGHT_UNIT);
        return new BackgroundImage(new Texture(Gdx.files.internal(pathToTexture)), position, this.HEIGHT_UNIT * speed);
    }

    /**
     * Add each button of the list into the stage
     */
    private void addButtonsToStage() {
        Iterator<BackgroundImage> iteratorBackgrounds = _backgroundsList.iterator();
        while(iteratorBackgrounds.hasNext()) {
            this.addActor(iteratorBackgrounds.next());
        }
    }
}
